function merge(arr) {
    if (arr.length > 1){
        let mid = arr.length / 2
        let left_arr = arr.slice(0,mid)
        let right_arr = arr.slice(mid,)
        merge(left_arr)
        merge(right_arr)
        let k = 0
        let i = 0
        let j = 0

        while (i<left_arr.length && j <right_arr.length){
            if(left_arr[i]<right_arr[j]){
                arr[k] = left_arr[i]
                i++
            }else {
                arr[k] = right_arr[j]
                j++
            }
            k++
        }
        while (i<left_arr.length){
            arr[k] = left_arr[i]
            i++
            k++
        }
        while (j<right_arr.length){
            arr[k] = right_arr[j]
            j++
            k++
        }

    }

}
let array = [100, 23, 45, 12, 25, 3, 90, 34]
merge(array)
console.log(array)
